package net.homelinux.chaoswg.io.renga.krypto.animations.Split8;

import net.homelinux.chaoswg.io.renga.core.animations.State;
import net.homelinux.chaoswg.io.renga.core.helper.datatypes.Octet;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned8Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBitFactory;

public class Split8State implements State {
    UnsignedNBit in = new Unsigned8Bit();
    Octet<UnsignedNBit,UnsignedNBit,UnsignedNBit,UnsignedNBit,UnsignedNBit,UnsignedNBit,UnsignedNBit,UnsignedNBit> out = new Octet<UnsignedNBit, UnsignedNBit, UnsignedNBit, UnsignedNBit,UnsignedNBit,UnsignedNBit,UnsignedNBit,UnsignedNBit>(new Unsigned8Bit (), new Unsigned8Bit (), new Unsigned8Bit (), new Unsigned8Bit(),new Unsigned8Bit (), new Unsigned8Bit (), new Unsigned8Bit (), new Unsigned8Bit());
    
    public Split8State (UnsignedNBit in ){
        this.in = in;
        UnsignedNBitFactory unbf = UnsignedNBitFactory.createUnsignedNBitFactory();
        out = new Octet<UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit> (unbf.get(in.getN()/8), unbf.get(in.getN()/8),unbf.get(in.getN()/8), unbf.get(in.getN()/8),unbf.get(in.getN()/8), unbf.get(in.getN()/8),unbf.get(in.getN()/8), unbf.get(in.getN()/8));
    }
    
    public Split8State () {} 

    public UnsignedNBit getIn() {
        return in;
    }

    public void setIn(UnsignedNBit in) {
        this.in = in;
    }

    public Octet<UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit> getOut() {
        return out;
    }

    public void setOut(Octet<UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit> out) {
        this.out = out;
    }
    
    public void setOperand(final int slot, final Object value) {
        if (value instanceof UnsignedNBit && slot == 0) {
            in = ((UnsignedNBit)value);
            UnsignedNBitFactory unbf = UnsignedNBitFactory.createUnsignedNBitFactory();
            out = new Octet<UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit,UnsignedNBit, UnsignedNBit> (unbf.get(in.getN()/8), unbf.get(in.getN()/8),unbf.get(in.getN()/8), unbf.get(in.getN()/8),unbf.get(in.getN()/8), unbf.get(in.getN()/8),unbf.get(in.getN()/8), unbf.get(in.getN()/8));
        }
    }
}
